package com.mark.mall.web.platform.controller;


import com.mark.mall.web.platform.dto.param.MemberLoginParam;
import com.mark.mall.web.platform.dto.param.MemberRegisterParam;
import com.mark.mall.web.platform.dto.param.MemberUpdateParam;
import com.mark.mall.common.resultBean.R;
import com.mark.mall.web.platform.entity.Member;
import com.mark.mall.web.platform.service.MemberService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

/**
 * <p>
 * 会员表 前端控制器
 * </p>
 *
 * @author admin
 * @since 2021-03-03
 */
@RestController
@RequestMapping("/web/member")
@Api(tags = "前台会员模块")
@RequiredArgsConstructor
public class MemberController {

    private final MemberService memberService;

    @ApiOperation(value = "前台首页会员登录功能", httpMethod = "POST")
    @PostMapping("login")
    public R<Boolean> login(@RequestBody @Valid MemberLoginParam param) {
        return memberService.login(param);
    }

    @ApiOperation(value = "前台首页会员注册功能", httpMethod = "POST")
    @PostMapping("register")
    public R<Boolean> register(@RequestBody @Valid MemberRegisterParam param) {
        return memberService.register(param);
    }

    @ApiOperation(value = "前台首页会员修改密码功能", httpMethod = "POST")
    @PostMapping("updatePassword")
    public R<Boolean> updatePassword(@RequestBody @Valid MemberUpdateParam param) {
        return memberService.updatePassword(param);
    }

    @ApiOperation(value = "会员详情", httpMethod = "GET")
    @GetMapping("memberDetail")
    public R<Member> memberDetail(String id) {
        return memberService.memberDetail(id);
    }

    @ApiOperation(value = "测试AR(Post)", httpMethod = "POST")
    @PostMapping("doSomethingByModelPost")
    public R<Boolean> doSomethingByModelPost(String type, String memberId) {
        return memberService.doSomethingByModelPost(type, memberId);
    }
}
